export default defineNuxtPlugin(() => {
  const setHtmlFontSize = () => {
    const htmlWidth = document.documentElement.clientWidth
    const remScreen = 375
    let htmlFontSize = (htmlWidth / remScreen) * 16

    if (htmlWidth > 640) {
      htmlFontSize = 16
    }

    document.documentElement.style.fontSize = `${htmlFontSize}px`
  }

  // 初始执行
  setHtmlFontSize()

  // 监听窗口尺寸变化
  window.addEventListener('resize', setHtmlFontSize)
})
